<template>
<div>
  <div id="d1">
    <div>
      <mt-header class="moban" title="模板详情">
      </mt-header>
    </div>
    <div id="div1">
    <div class="d2" style="margin-top:10vh;">
      抽奖形式：
      <input  type="radio" value="1"  v-model="leixing" name="A"/>大转盘
      <input type="radio" value="2"  v-model="leixing" name="A" />九宫格
      <input type="radio" value="3"  v-model="leixing" name="A" />刮刮乐
    </div>
    <div class="d3">
      活动标题:
      <input id="biaoti" value="huati" v-model="huati" placeholder="异凡文化的抽奖测试" style="height:5vh; width:50vw;margin-top:10vh;border-radius: 5px;" type="text"/>
    </div>
    <div id="inbtn">
    <div id="shijian">
      活动时间:
      <input style="width:50vw;height:5vh;border-radius: 5px;" id="dateTime" value="n" v-model="n" type="date"/>
      <br><input id="datetime1" style="width:50vw;height:5vh;border-radius: 5px;"
        value="y"
        v-model="y"
        type="date"
      />
    </div>
    <button @click="onclick" class="btn">保存并发布</button>
    </div>
  </div>
  </div>
  </div>
</template>
<script>
export default {
 
  data() {
    return {
      n: "",
      y: "",
      huati:"",
      leixing:1
    };
  },
   watch:{
    leixing(a){
       this.leixing=a
        console.log(a)
      }

   },
  methods: {
    time() {
      var da = new Date();
      var nian = da.getFullYear();
      var yue = da.getMonth() + 1;
      var ri = da.getDate();
      if (yue < 10) {
        yue = "0" + yue;
      }
      if (ri < 10) {
        ri = "0" + ri;
      }
      this.n = `${nian}-${yue}-${ri}`;
      if (parseInt(yue) == 12) {
        nian += 1;
      } else {
        yue = parseInt(yue) + 1;
        if (yue < 10) {
          yue = "0" + yue;
        }
      }
      this.y = `${nian}-${yue}-${ri}`;
      // console.log(this.y);
    },
  onclick(){
    if(biaoti.value!=''){
     console.log("保存成功")
      this.axios.post('http://pw.clianmaimai.com:8071/dn/insert_lottery',`use_id=1&prize_date=${this.n},${this.y}&prize_name=${this.huati}&prize_type=${this.leixing}`).then(result=>{
      console.log(result);
      console.log(this.huati);
      console.log(this.n);
      console.log(this.leixing);
      this.$router.push('/header')
    })
      return true;
    }{
      alert("保存失败")
      return false
    }
  }
  },
  created() {
    this.time();
  },
  mounted(){
    
  }
};
</script>
<style scoped>
.moban{
    width: 100%;
}
#d1 .d2 {
  margin-top: 5vw;
}
.d3{
  margin-bottom: 2vw;
}
#div1{
  height: 100%;
  margin:0 5vw;
}
.btn {
  width:50vw;
  border-radius: 15px;
  background-color:rgb(38,162,255);
  height:5vh;
  margin-left: 19vw;
}
#dateTime{
  margin: 5vw 0 5vw;
}
#datetime1{
  margin-bottom: 40vw;
  margin-left: 19vw;
}
</style>
